<template>
  <div>
    <!-- 售后回访录入-->
    <TopFilter ref="topFilter" :list="topFilterList" :cols="3" :rows="2" labelWidth="150" :collapse="true" @filterChange="changeHandle"></TopFilter>
    <FilterTable
      ref="table"
      :columns="columns"
      :datakey="'rows'"
      :fetchapi="fetchapi"
      :params="fetchParams"
      selectionType="single"
      columnsRef="clresultEntry"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="onRowSelectChange"
    >
      <template slot="controls">
        <el-button size="small" type="primary" @click="() => this.openHandler('openOwner', {})">车主信息</el-button>
        <el-button size="small" type="primary" @click="() => this.openHandler('openVehicle', {})">车辆信息</el-button>
        <el-button size="small" type="primary" @click="() => this.openHandler('remindInputs', {})">问卷录入</el-button>
        <el-button size="small" type="primary" @click="() => this.openHandler('repairHistory', {})">维修历史</el-button>
        <el-button size="small" type="primary" @click="() => this.openHandler('visitHistory', {})">回访历史</el-button>
      </template>
    </FilterTable>

    <!--车主信息-->
    <Drawer :visible.sync="ownerActions.visible" :title="ownerActions.title" width="90%" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <addOwnerPanel :type.sync="ownerActions.type" :resData="this.vinData" @close="closeHandler_owner" />
    </Drawer>
    <!-- 车辆信息 -->
    <Drawer :visible.sync="vehicleActions.visible" :title="vehicleActions.title" width="90%" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <addVehiclePanel :type.sync="vehicleActions.type" :resData="this.vinData" @close="closeHandler_vehicle" />
    </Drawer>
    <!--问卷录入-->
    <Drawer :visible.sync="actions.visible" :title="actions.title" destroyOnClose :width="1300" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <RemindInputs :formData="this.resData" :type.sync="actions.type" @close="closeQuestionNaire"></RemindInputs>
    </Drawer>
    <!-- 维修历史-->
    <BaseDialog :visible.sync="historyActions.visible" :title="historyActions.title" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <repairHistory :carInfo="carInfoObj" :vin="carVin" @close="close_history" />
    </BaseDialog>
    <!-- 回访历史 -->
    <BaseDialog :visible.sync="returnActions.visible" :title="returnActions.title" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <salesVisitHistory :formData="returnHisData" @close="closeReturnHis"></salesVisitHistory>
    </BaseDialog>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { notifyAction, isFormEmpty, findTableItem } from '@/utils';
import salesVisitHistory from './salesVisitHistory.vue'; // 回访历史
import RemindInputs from './remindInputs.vue'; // 问卷录入
import { getAppId } from '@/assets/js/auth';
import { searchRoleByCodes } from '@/api/customerCare/visitAllocation/getVisitInfo';
import repairHistory from '@/pages/repair/repairReception/customer/repairHistory'; // 维修历史
import addOwnerPanel from '@/pages/customerRepair/customerInfo/ownerVehicleManagement/addOwnerPanel.vue'; // 客户档案
import addVehiclePanel from '@/pages/customerRepair/customerInfo/ownerVehicleManagement/addVehiclePanel.vue'; // 客户档案
import { getVisitInfo } from '@/api/customerRepair/afterSaleVisit/resultEntry';
import { searchRoleByCode } from '@/api/common/empSelect/index';
import dictCode from '@/utils/dictCode';
import { getAllUser } from '@/api/customerRepair/usedCarVisit/resultEntry';
import { arrayObjDeWeight } from '@/utils/index';
import { getPinpSelect, getChexSelect, getCheModelSelect } from '@/api/repair/repairReception/customer/brand.js';
import { getDealerUser } from '@/api/customerRepair/customerComplaint/customerComplaintReception';
import { getWxlxSelect } from '@/api/repair/repairReception/customer';

export default {
  name: 'shouhouhuifangzhuyemian',
  components: {
    addOwnerPanel,
    addVehiclePanel,
    repairHistory,
    salesVisitHistory,
    RemindInputs
  },
  mixins: [dictionary],
  data() {
    this.BaseTable = null;
    this.type = '';
    this.buttonType = '';
    this.resData = {};
    this.selectData = null;
    this.vinData = {};
    return {
      topFilterList: this.createTopFilterList(),
      columns: this.confirmColumns(),
      ownerActions: { title: '', type: '', visible: false }, // 车主界面
      vehicleActions: { title: '', type: '', visible: false }, // 车辆界面
      historyActions: { title: '', type: '', visible: false }, // 维修历史界面
      returnActions: { title: '', type: '', visible: false }, // 回访历史界面
      actions: { title: '', type: '', visible: false }, // 问卷录入界面
      fetchapi: getVisitInfo,
      fetchParams: { xhrAbort: true },
      repairHistoryData: {}, // 维修历史数据
      questionnaireData: {}, // 问卷录入数据
      returnHisData: {}, // 回访历史数据
      afterVal: '',
      roNo: '', // 预约单号
      tableDataList: [], // table列表数据
      carVin: '', // 维修历史需要底盘号参数
      carInfoObj: {}, // 维修历史需要的对象
      repairTypeList: [], // 维修类型集合
      userList: [] // 人员集合
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table;
    this.queryRepairTypeDict();
    // this.addQuestionnaireType();
    // this.getEmp();
    // this.after();
    this.getAllUser();
    // 获取客服专员
    this.getCustomerService();
    // 获取品牌
    this.getBrand();
  },
  methods: {
    createTopFilterList() {
      return [
        {
          type: 'RANGE_DATE',
          label: '结清日期',
          fieldName: 'deltveryBeginDate|deltveryEndDate',
          // labelOptions: {
          //   fieldName: 'dateType',
          //   initialValue: 1002,
          //   itemList: [
          //     { text: '交车日期', value: 1001 },
          //     { text: '跟踪日期', value: 1002 },
          //     { text: '录入日期', value: 1003 },
          //   ]
          // },
          rules: [{ required: false, message: '请选择日期', trigger: 'change' }]
        },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'license'
        },
        {
          type: 'INPUT',
          label: '工单号',
          fieldName: 'roNo'
        },
        {
          type: 'INPUT',
          label: '送修人手机',
          fieldName: 'delivererMobile'
        },
        {
          type: 'SELECT',
          label: '跟踪员',
          fieldName: 'stalker',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '跟踪状态',
          fieldName: 'trackStatus',
          itemList: this.createDictList(8058),
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin'
        },
        // {
        //   type: 'INPUT',
        //   label: '送修人电话',
        //   fieldName: 'delivererPhone'
        // },
        {
          type: 'SELECT',
          label: '品牌',
          fieldName: 'brand',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '回访失败原因',
          fieldName: 'reasonsFailOfVisit',
          itemList: this.createDictList(1594)
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '跟踪状态',
          dataIndex: 'trackStatus',
          width: 150,
          showOverflowTooltip: true,
          render: props => {
            return <span>{this.createDictText(props.row.trackStatus, 8058)}</span>;
          }
        },
        {
          title: '工单号',
          dataIndex: 'roNo',
          showOverflowTooltip: true
        },
        // {
        //   title: '预检单号',
        //   dataIndex: 'fwgw',
        //   showOverflowTooltip: true
        // },
        {
          title: '开单日期',
          dataIndex: 'roCreateDate',
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '结清日期',
          dataIndex: 'deliveryDate',
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '销售日期',
          dataIndex: 'salesDate',
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '工单维修类型',
          dataIndex: 'repairTypeCode',
          render: props => {
            return <span>{this.getText('repairCode', props.row.repairTypeCode)}</span>;
          }
        },
        {
          title: 'VIN',
          dataIndex: 'vin',
          showOverflowTooltip: true
        },
        {
          title: '满意度',
          dataIndex: 'returnVisitResults',
          width: 150,
          showOverflowTooltip: true,
          dictItems: this.createDictList(8043)
        },
        {
          title: '回访失败原因',
          dataIndex: 'reasonsFailOfVisit',
          showOverflowTooltip: true,
          dictItems: this.createDictList(1594)
        },
        {
          title: '车牌号',
          dataIndex: 'license',
          showOverflowTooltip: true
        },
        {
          title: '品牌',
          dataIndex: 'brandName',
          showOverflowTooltip: true
        },
        {
          title: '车系',
          dataIndex: 'seriesName',
          showOverflowTooltip: true
        },
        {
          title: '车型',
          dataIndex: 'modelName',
          showOverflowTooltip: true
        },
        {
          title: '车主姓名',
          dataIndex: 'ownerName',
          showOverflowTooltip: true
        },
        {
          title: '车主地址',
          dataIndex: 'address',
          showOverflowTooltip: true
        },
        {
          title: '车主E-MAIL',
          dataIndex: 'email',
          showOverflowTooltip: true
        },
        {
          title: '送修人',
          dataIndex: 'deliverer',
          showOverflowTooltip: true
        },
        {
          title: '送修人性别',
          dataIndex: 'delivererGender',
          showOverflowTooltip: true,
          render: props => {
            return <span>{this.createDictText(props.row.delivererGender, 8012)}</span>;
          }
        },
        // {
        //   title: '送修人电话',
        //   dataIndex: 'delivererPhone',
        //   showOverflowTooltip: true
        // },
        {
          title: '送修人手机',
          dataIndex: 'delivererMobile',
          showOverflowTooltip: true
        },
        {
          title: '服务专员',
          dataIndex: 'serviceAdvisor',
          showOverflowTooltip: true,
          dictItems: []
        },
        {
          title: '责任技师',
          dataIndex: 'CHIEF_TECHNICIAN',
          dictItems: [],
          width: 150
        },
        {
          title: '维修技师',
          dataIndex: 'technicianList',
          showOverflowTooltip: true,
          render: props => {
            return <span>{this.tranlate(props.row.technicianList)}</span>;
          }
        },
        {
          title: '是否预约客户',
          dataIndex: 'sfyykh',
          showOverflowTooltip: true,
          dictItems: this.createDictList(1004)
        },
        {
          title: '进厂里程',
          dataIndex: 'inMileage',
          showOverflowTooltip: true
        },
        {
          title: '跟踪人',
          dataIndex: 'stalker',
          showOverflowTooltip: true,
          dictItems: []
        },
        // {
        //   title: '录入人',
        //   dataIndex: 'xslc',
        //   showOverflowTooltip: true,
        //   render: props => {
        //     return <span>{this.getText('user', props.row.xslc)}</span>;
        //   }
        // },
        {
          title: '跟踪日期',
          dataIndex: 'trackDate',
          width: 150,
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '跟踪次数',
          dataIndex: 'trackNum',
          showOverflowTooltip: true
        },
        {
          title: '结算单号',
          dataIndex: 'balanceNo',
          showOverflowTooltip: true
        },
        {
          title: '是否本公司购车',
          dataIndex: 'isSelfCompany',
          showOverflowTooltip: true,
          dictItems: this.createDictList(1004),
          render: props => {
            return <span>{this.createDictText(props.row.isSelfCompany, '1004')}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'remark',
          showOverflowTooltip: true
        },
        {
          title: '下次维修提醒',
          dataIndex: 'nextMaintenanceReminder',
          showOverflowTooltip: true
        },
        {
          title: '预约单号',
          dataIndex: 'bookingOrderNo',
          showOverflowTooltip: true
        }
      ];
    },
    createTableColumnsBeijing() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '跟踪状态',
          dataIndex: 'trackStatus',
          width: 150,
          showOverflowTooltip: true,
          render: props => {
            return <span>{this.createDictText(props.row.trackStatus, 8058)}</span>;
          }
        },
        {
          title: '工单号',
          dataIndex: 'roNo',
          showOverflowTooltip: true
        },
        // {
        //   title: '预检单号',
        //   dataIndex: 'fwgw',
        //   showOverflowTooltip: true
        // },
        {
          title: '开单日期',
          dataIndex: 'roCreateDate',
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '结清日期',
          dataIndex: 'deliveryDate',
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '销售日期',
          dataIndex: 'salesDate',
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '工单维修类型',
          dataIndex: 'repairTypeCode',
          render: props => {
            return <span>{this.getText('repairCode', props.row.repairTypeCode)}</span>;
          }
        },
        {
          title: 'VIN',
          dataIndex: 'vin',
          showOverflowTooltip: true
        },
        {
          title: '满意度',
          dataIndex: 'returnVisitResults',
          width: 150,
          showOverflowTooltip: true,
          dictItems: this.createDictList(8043)
        },
        {
          title: '回访失败原因',
          dataIndex: 'reasonsFailOfVisit',
          showOverflowTooltip: true,
          dictItems: this.createDictList(1594)
        },
        {
          title: '车牌号',
          dataIndex: 'license',
          showOverflowTooltip: true
        },
        {
          title: '品牌',
          dataIndex: 'brandName',
          showOverflowTooltip: true
        },
        {
          title: '车系',
          dataIndex: 'seriesName',
          showOverflowTooltip: true
        },
        {
          title: '车型',
          dataIndex: 'modelName',
          showOverflowTooltip: true
        },
        {
          title: '车主姓名',
          dataIndex: 'ownerName',
          showOverflowTooltip: true
        },
        {
          title: '车主地址',
          dataIndex: 'address',
          showOverflowTooltip: true
        },
        {
          title: '车主E-MAIL',
          dataIndex: 'email',
          showOverflowTooltip: true
        },
        {
          title: '送修人',
          dataIndex: 'deliverer',
          showOverflowTooltip: true
        },
        // {
        //   title: '送修人性别',
        //   dataIndex: 'delivererGender',
        //   showOverflowTooltip: true,
        //   render: props => {
        //     return <span>{this.createDictText(props.row.delivererGender, 8012)}</span>;
        //   }
        // },
        // {
        //   title: '送修人电话',
        //   dataIndex: 'delivererPhone',
        //   showOverflowTooltip: true
        // },
        {
          title: '送修人手机',
          dataIndex: 'delivererMobile',
          showOverflowTooltip: true
        },
        {
          title: '服务专员',
          dataIndex: 'serviceAdvisor',
          showOverflowTooltip: true,
          dictItems: []
        },
        {
          title: '责任技师',
          dataIndex: 'CHIEF_TECHNICIAN',
          dictItems: [],
          width: 150
        },
        {
          title: '维修技师',
          dataIndex: 'technicianList',
          showOverflowTooltip: true,
          render: props => {
            return <span>{this.tranlate(props.row.technicianList)}</span>;
          }
        },
        {
          title: '是否预约客户',
          dataIndex: 'sfyykh',
          showOverflowTooltip: true,
          dictItems: this.createDictList(1004)
        },
        {
          title: '进厂里程',
          dataIndex: 'inMileage',
          showOverflowTooltip: true
        },
        {
          title: '跟踪人',
          dataIndex: 'stalker',
          showOverflowTooltip: true,
          dictItems: []
        },
        // {
        //   title: '录入人',
        //   dataIndex: 'xslc',
        //   showOverflowTooltip: true,
        //   render: props => {
        //     return <span>{this.getText('user', props.row.xslc)}</span>;
        //   }
        // },
        {
          title: '跟踪日期',
          dataIndex: 'trackDate',
          width: 150,
          showOverflowTooltip: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss'
        },
        {
          title: '跟踪次数',
          dataIndex: 'trackNum',
          showOverflowTooltip: true
        },
        {
          title: '结算单号',
          dataIndex: 'balanceNo',
          showOverflowTooltip: true
        },
        {
          title: '是否本公司购车',
          dataIndex: 'isSelfCompany',
          showOverflowTooltip: true,
          dictItems: this.createDictList(1004),
          render: props => {
            return <span>{this.createDictText(props.row.isSelfCompany, '1004')}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'remark',
          showOverflowTooltip: true
        },
        {
          title: '下次维修提醒',
          dataIndex: 'nextMaintenanceReminder',
          showOverflowTooltip: true
        },
        {
          title: '预约单号',
          dataIndex: 'bookingOrderNo',
          showOverflowTooltip: true
        }
      ];
    },
    changeHandle(val) {
      // this.queryMainTableData();
      this.fetchParams = Object.assign({}, val, { xhrAbort: false });
    },
    // 选中事件
    onRowSelectChange(val) {
      if (!val.length) {
        this.selectData = null;
      } else {
        this.selectData = val[0];
      }
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },

    // 打开车主/车辆/维修历史/问卷录入界面
    openHandler(type, val) {
      if (isFormEmpty(this.selectData)) {
        return notifyAction('请选择一条数据！', 'warning');
      } else {
        if (type === 'openOwner') {
          if (isFormEmpty(this.selectData.ownerNo)) {
            return notifyAction('车主编号不能为空！', 'warning');
          }
          this.ownerActions = { title: '车主明细', type: 'show', visible: true };
          this.vinData = this.selectData;
        } else if (type === 'openVehicle') {
          if (isFormEmpty(this.selectData.ownerNo)) {
            return notifyAction('车主编号不能为空！', 'warning');
          }
          if (isFormEmpty(this.selectData.vin)) {
            return notifyAction('车辆VIN不能为空！', 'warning');
          }
          this.vehicleActions = { title: '车辆明细', type: 'show', visible: true };
          this.vinData = this.selectData;
        } else if (type === 'remindInputs') {
          this.selectData.serviceAdvisor = this.userList.find(x => x.value === this.selectData.serviceAdvisor) ? this.userList.find(x => x.value === this.selectData.serviceAdvisor).text : '';
          if (this.selectData.trackStatus === 80581001) {
            this.actions = { title: '回访信息录入', type: 'add', visible: true };
          } else if (this.selectData.trackStatus === 80581002) {
            this.actions = { title: '回访信息录入', type: 'edit', visible: true };
          } else {
            this.actions = { title: '回访信息录入', type: 'show', visible: true };
          }
          this.resData = this.selectData;
        } else if (type === 'repairHistory') {
          if (isFormEmpty(this.selectData.vin)) {
            return notifyAction('车辆VIN不能为空！', 'warning');
          }
          this.historyActions = { title: '维修历史', type: 'detail', visible: true };
          this.carVin = this.selectData.vin;
          this.carInfoObj = this.selectData;
        } else if (type === 'visitHistory') {
          this.returnActions = { title: '回访历史', type: 'detail', visible: true };
          this.returnHisData = this.selectData;
        }
      }
    },
    // 关闭车主界面
    closeHandler_owner(val) {
      this.ownerActions.visible = val;
    },
    // 关闭车辆界面
    closeHandler_vehicle(val) {
      this.vehicleActions.visible = val;
    },
    // 关闭问卷录入界面
    closeQuestionNaire(val, params) {
      this.actions.visible = val;
      this.fetchParams = { ...this.fetchParams };
      // this.questionnaire = val;
      // if (params === 'refresh') {
      //   this.tableDataList = [];
      //   this.queryMainTableData();
      //   // this.canCalList()
      //   this.fetchParams = { ...this.fetchParams };
      // }
    },
    // 关闭维修历史界面
    close_history(val) {
      this.historyActions.visible = val;
    },
    // 关闭回访历史界面
    closeReturnHis(val) {
      this.returnActions.visible = val;
    },
    // 获取维修类型
    async queryRepairTypeDict() {
      let res = await getWxlxSelect();
      if (res.resultCode == 200) {
        this.repairTypeList = res.data;
      }
    },
    // 获取人员
    async getAllUser() {
      const res = await getAllUser();
      let data = arrayObjDeWeight(res.data, 'userId'); // 人员去重(解决前端报错)
      this.userList = data.map(x => ({
        value: x.userId + '',
        text: x.employeeName
      }));
      this.columns.find(item => item.dataIndex === 'CHIEF_TECHNICIAN').dictItems = this.userList; // 责任技师
      let targetTableItems = [findTableItem(this.columns, 'serviceAdvisor'), findTableItem(this.columns, 'stalker')];
      targetTableItems.forEach(item => {
        item.dictItems = this.userList;
      });
    },
    getText(type, val) {
      if (type === 'repairCode') {
        return this.repairTypeList.find(x => x.REPAIR_TYPE_CODE === val) ? this.repairTypeList.find(x => x.REPAIR_TYPE_CODE === val).REPAIR_TYPE_NAME : '';
      } else if (type === 'user') {
        return this.userList.find(x => x.value === val) ? this.userList.find(x => x.value === val).text : '';
      }
    },
    // 获取客服专员
    async getCustomerService() {
      let roleParm = {
        role: dictCode.CUSTOMER_SERVICE_SPECIALIST
      };
      const res = await searchRoleByCodes(roleParm);
      this.topFilterList.find(item => item.fieldName === 'stalker').itemList = res.data.map(x => ({ value: x.userId, text: x.employeeName }));
    },
    //翻译维修技师
    tranlate(technicianList) {
      let arr = '';
      if (technicianList) {
        let list = technicianList.split(',');
        list = new Set(list);
        console.log(1111111);
        list.forEach(x => {
          arr += this.userList.find(y => y.value == x)?this.userList.find(y => y.value == x).text:'' + ',';
        });
        console.log(222222);
        arr = arr.substring(0, arr.length - 1);
      }
      return arr;
    },
    // 品牌
    async getBrand() {
      const res = await getPinpSelect();
      this.topFilterList.find(item => item.fieldName === 'brand').itemList = res.data.map(x => ({
        value: x.brandId + '',
        text: x.brandName
      }));
    },
    // 问卷录入
    inputClick() {
      // if (!this.selectFlag) {
      //   this.$message({
      //     type: 'warning',
      //     message: '请选择表单数据!'
      //   });
      // } else {
      //   if (this.selectData.hfzt === 15921003 || this.selectData.hfzt === 15921004) {
      //     this.$message({
      //       type: 'warning',
      //       message: '该回访单已回访!'
      //     });
      //     return false;
      //   }
      //   this.buttonType = 1;
      //   this.questionnaireData.FH_FLAG = 'true'; // 根据这个参数去查询所有状态的结算单的维修历史
      //   this.questionnaireData = Object.assign(this.questionnaireData, _.cloneDeep(this.selectData));
      //   this.questionnaire = true;
      // }
    },
    // canCalList() {
    //   this.fetchParams = { ...this.fetchParams };
    //   // this.fetchParams = Object.assign({}, this.dataList, { xhrAbort: false });
    // },

    async getEmp() {
      console.log('getEmp');
      // const res = await getDealerUser();
      /* 服务顾问 */
      let roleParm = {
        role: dictCode.SERVICE_CONSULTANT
      };
      const res = await searchRoleByCode(roleParm);
      // let data = arrayObjDeWeight(res.data, 'userId'); // 人员去重(解决前端报错)
      this.topFilterList.find(item => item.fieldName === 'fwgw').itemList = res.data.map(x => ({
        value: x.employeeName + '-' + x.userId,
        text: x.employeeName
      }));
      /* 回访员 */
      const csParams = {
        role: dictCode.CUSTOMER_SERVICE_SPECIALIST
      };
      const csRes = await searchRoleByCodes(csParams);
      // const csData = arrayObjDeWeight(csRes.data, 'userId');
      this.topFilterList.find(item => item.fieldName === 'hfr').itemList = csRes.data.map(x => ({
        value: x.userId,
        text: x.employeeName
      }));
    },

    // 查询table主数据
    async queryMainTableData() {
      // console.log('查询table主数据');
      // let formParams = await this.$refs.topFilter.GET_FORM_DATA();
      // formParams[1].visitType = '15721001'; // 售后回访
      // console.log(formParams);
      // this.$refs.table.START_LOADING();
      // try {
      //   let res = await this.fetchApi(formParams[1] || {});
      //   if (res.resultCode == 200) {
      //     this.tableDataList = res.data;
      //     console.log('table赋值');
      //     console.log(this.tableDataList);
      //   }
      // } catch (err) {
      //   console.log(err, '查询table主数据失败');
      // } finally {
      //   this.$refs.table.STOP_LOADING();
      // }
    },
    confirmColumns() {
      let appId = getAppId();
      if (appId == 'beijing') {
        return this.createTableColumnsBeijing();
      } else {
        return this.createTableColumns();
      }
    },
    after() {
      console.log('after');
      let that = this;
      CallCenter.addEventListener('after', function(json) {
        console.log(json.followData.RO_NO, '查看工单号');
        // json.followData

        if (that.afterVal === '' || that.afterVal !== JSON.stringify(json)) {
          that.afterVal = JSON.stringify(json);
          if (json.followData.RO_NO == this.roNo) {
          }
        }
        let url = json.recordDownloadUrl + '/' + json.mediano + '?file=' + json.filename;
      });
    },
    // 增加问卷类型
    addQuestionnaireType() {
      this.questionnaireData = Object.assign(this.questionnaireData, { questionnaireType: '80031002' });
    }
  }
};
</script>

<style lang="less" scoped></style>
